<?php
/**************************************************
bind to an active directory ldap server and look
something up.
************************************************** */
	$searchfor = $_SESSION["login"];
	$searchfield="samaccountname"; //in what active directory field do you want to search for the string?

	$ldaphost = "adserver"; //your ldap server dns name or ip address
	$dn = "dc=example,dc=com"; //put your base dn here
	$ldapuserdomain = "@example.com"; //needs the @, but not always the same as the ldap server domain

$ldapuser = $_SESSION["login"]; //a valid active directory login
$ldapuserpassword = $_SESSION["password"];

//$ldapfieldstofind = array("cn", "givenname", "samaccountname", "homedirectory", "telephonenumber", "mail");
$ldapfieldstofind = array("*");
$cnx = ldap_connect($ldaphost) or die("could not connect to ldap");
ldap_set_option($cnx, LDAP_OPT_PROTOCOL_VERSION, 3); //set the ldap protocol used by your ad service
ldap_set_option($cnx, LDAP_OPT_REFERRALS, 0); //this was necessary for my ad to do anything
ldap_bind($cnx,$ldapuser.$ldapuserdomain,$ldapuserpassword) or die("could not bind to ldap");
?>
